<template>
  <Layout class="p-5 bg-white">
    <h1>预约接待详细</h1>
    <!--表单-->
    <Form :label-width="80">
      <FormItem class="w-50" label="回访类型">
        <Input v-model="backview.type" placeholder="请输入回访类型"></Input>
      </FormItem>

      <FormItem class="w-50" label="回访人">
        <Input v-model="backview.autor" placeholder="请输入回访人"></Input>
      </FormItem>

      <FormItem class="w-50" label="回访描述">
        <Input v-model="backview.des" placeholder="请输入回访描述"></Input>
      </FormItem>

      <FormItem class="w-50" label="回访结果">
        <Input v-model="backview.result" placeholder="请输入回访结果"></Input>
      </FormItem>

      <FormItem class="w-50" label="回访日期">
        <Input v-model="backview.dateTime" placeholder="请输入回访日期"></Input>
      </FormItem>

      <FormItem class="w-50" label="回访方式">
        <Input v-model="backview.method" placeholder="请输入回访方式"></Input>
      </FormItem>

      <FormItem class="w-50" label="回访阶段">
        <Input
          v-model="backview.stage"
          disabled
          placeholder="请输入回访方式"
        ></Input>
      </FormItem>

      <FormItem class="w-50" label="添加人">
        <Input v-model="backview.cu" placeholder="请输入添加人"></Input>
      </FormItem>

      <FormItem class="w-50" label="添加时间">
        <Input v-model="backview.ct" placeholder="请输入添加时间"></Input>
      </FormItem>

      <FormItem class="w-50" label="更新者">
        <Input v-model="backview.uu" placeholder="请输入更新者"></Input>
      </FormItem>

      <FormItem class="w-50" label="新增时间">
        <Input v-model="backview.ut" placeholder="请输入新增时间"></Input>
      </FormItem>
      <!--按钮-->
      <FormItem class="text-right">
        <Button @click="submit" type="primary">提交</Button>
        <Button @click="cancel" class="ml-2">取消</Button>
      </FormItem>
    </Form>
    <!--表单-->
  </Layout>
</template>

<script>
export default {
  data() {
    return {
      backview: {
        id: null,
        type: '',
        autor: null,
        des: '',
        result: '',
        dateTime: '',
        stage: '',
        method: '',
        cu: null,
        ct: '',
        uu: null,
        ut: '',
      },
      allStages: [],
    }
  },
  methods: {
    changeP: function(selectedPermissionId) {},
    submit: function() {
      let self = this

      delete self.$data.permission.cu
      delete self.$data.permission.ct
      delete self.$data.permission.uu
      delete self.$data.permission.ut

      //更新backview 待定
      this.http
        .put({
          url: '/backview/info',
          param: self.$data.backview,
        })
        .then((data) => {
          self.message.info('修改成功')
          self.$tabs.close()
        })
    },
    cancel: function() {
      this.$tabs.close()
    },
    init: function() {
      //init
      let self = this
      this.http
        .get({
          url: '/backview/all',
        })
        .then((data) => {
          //这里获取backview阶段详细信息
          self.$data.allStages.push({
            //XX
            id: 0,
            name: '线索阶段',
          })
          for (let index in data) {
            let allStages = {}
            allStages.name = data[index].name
            self.$data.allStages.push(allStages) //XX
          }
          self.http
            .get({
              url: '/backview/info',
              param: {},
            })
            .then((data) => {
              self.$data.backview = data //将这条信息返回到更新表单
            })
        })
    }, //init
  },
  created: function() {
    //this.$data.permission.permissionId = this.$route.params.pId;
    this.init()
  },
}
</script>
